﻿using EYCmsAdmin.Domain.Models;
using FluentNHibernate.Mapping;

namespace EYCmsAdmin.NHibernate.Mappings
{
    public class SectionMap : ClassMap<Section>
    {
        public SectionMap()
        {
            Id(x => x.Id).UnsavedValue(0).GeneratedBy.Identity();
            Map(x => x.Name).Length(50).Not.Nullable();
            HasManyToMany(x => x.Permissions).Table("PermissionToSection").ChildKeyColumn("SectionId").ParentKeyColumn("PermissionId").Cascade.None();
            HasManyToMany(x => x.EntityMenuItems).Table("EntityMenuItemToSection").ChildKeyColumn("SectionId").ParentKeyColumn("EntityMenuItemId").Cascade.None();
        }
    }
}